<template>
  <div ref="chart" class="line-chart" />
</template>

<script>
import * as echarts from 'echarts'
import resize from '@/minxins/resize'

export default {
  name: 'LineChart',
  mixins: [resize],
  mounted() {
    const myEcharts = echarts.init(this.$refs.chart)
    myEcharts.setOption({
      grid: {
        top: 0,
        bottom: 0,
        left: -10,
        right: -10
      },
      xAxis: {
        show: false,
        data: [
          '一月',
          '二月',
          '三月',
          '四月',
          '五月',
          '六月',
          '七月',
          '八月',
          '九月',
          '十月',
          '十一月',
          '十二月'
        ]
      },
      yAxis: {
        show: false
      },
      series: {
        type: 'line',
        data: [44, 126, 55, 88, 133, 99, 33, 113, 63, 98, 77, 123],
        // 曲线
        smooth: true,
        // 拐点
        itemStyle: {
          opacity: 0
        },
        // 填充区域
        areaStyle: {
          color: {
            type: 'linear',
            x: 0,
            y: 0,
            x2: 0,
            y2: 1,
            colorStops: [
              {
                offset: 0,
                color: '#975fe4' // 0% 处的颜色
              },
              {
                offset: 1,
                color: '#fff' // 100% 处的颜色
              }
            ],
            global: false // 缺省为 false
          }
        },
        // 线
        lineStyle: {
          color: '#975fe4'
        }
      }
    })
    this.myEcharts = myEcharts
  }
}
</script>

<style lang="sass" scoped>
.line-chart
  width: 100%
  height: 100%
</style>
